package com.wm.blog_gateway.auth;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/***
 * @ClassName: UserDetailsImpl
 * @Description: userDetails实现类  spring security   实现了UserDetails接口，只留必需的属性，也可添加自己需要的属性
 * @Author: wm_yu
 * @Create_time: 16:41 2020-3-30
 */
public class UserDetailsImpl implements UserDetails {

    /**
     * 登录用户名，最好别用驼峰命名
     */
    private String username;
    /**
     * 登录密码,最好别用驼峰命名
     */
    private String password;

    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    private Collection<? extends GrantedAuthority> authorities;

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

}
